﻿#region License
// (c) Intergen.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MediaWiki.Office.Model.Utilities
{
  public static class BitUtils
  {
    public static int ConvertToInt32(string input)
    {
      if (input == null)
        throw new ArgumentNullException("input");

      int len = input.Length;
      int sum = 0, position = 0;
      for (int i = len - 1; i >= 0; i--)
      {
        if (input[i] == '1')
          sum = sum + (1 << position);
        position++;
      }

      return sum;
    }
  }
}